package cn.ljy.uem.dao;

import cn.ljy.authority.dao.BaseMapper;
import cn.ljy.uem.model.SchoolCourse;
import cn.ljy.uem.model.SchoolStudent;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.List;

@Mapper
public interface SchoolStudentMapper extends BaseMapper<SchoolStudent> {

//查找班级姓名
    @Select("SELECT school_class.`name` FROM school_student,school_class WHERE school_student.class_id=school_class.id order by school_student.id asc")
    List<String> getClassNAll();


//    查找名字不重名
    @Select("select count(1) from school_student where name=#{name} and id!=#{id}")
    int countByNameAndNotId(String name,Serializable id);

    @Select("select count(1) from school_student where name=#{name}")
    int countNickName(String nickName);

    //    查找学号不重复
    @Select("select count(1) from school_student where student_number=#{studentNumber} and id!=#{id}")
    int countByStudentNumberAndNotId(String studentNumber, Serializable id);

    /**
     * 通过账户名和密码查找符合的账户数量
     * @param username 账户名
     * @param password 密码
     * @return 返回找到的账户数
     */
    @Select("select count(1) from school_student where username=#{username} and password=#{password}")
    int countByUsernameAndPassword(String username,String password);

    @Select("select * from school_student where username=#{username}")
    SchoolStudent findByUsername(String username);

    /**
     * 获取user表中相对应的教师信息
     */
    @Select("SELECT * FROM school_student WHERE user_id=#{userid}")
    SchoolStudent getByUserId(java.io.Serializable userid);


    /**
     * 获取学生对应教学任务下所有课程
     *
     */

    List<SchoolCourse> getCourseByClassId(java.io.Serializable ClassId);


    /**
     * 获取学生账户Id
     *
     */
    List<Serializable> findUserIdsByIds(java.io.Serializable[] ids);

    Long findSysDepartmentIdByClassId(java.io.Serializable ClassId);

}
